//
//  AppDelegate+configuration.m
//  UEAssistant
//
//  Created by mac on 2017/10/27.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "AppDelegate+configuration.h"
#import "OrderBaseControl.h"
#import "TabbarController.h"
#import "LoginViewController.h"
#import "NavigationController.h"
#import <IQKeyboardManager.h>
#import "LeftSortsViewController.h"
#import "ProductViewController.h"
#import "UploadViewController.h"
#import "MJ_TaskViewController.h"
#import <MMDrawerController/MMDrawerController.h>
#import "MJ_UserMessage.h"
#import "MJResultModel.h"
#import "MJVersionCheckModel.h"
#import "UIViewController+CurrentController.h"
@implementation AppDelegate (configuration)

- (void)configurationApplicationBaseContainer{
    TGLog(@"当前登录用户的userType = %zd",CurrentUserType);
    
    if ([userManager userIsOnline]) {
        switch (CurrentUserType) {
            case 1:
                //1.2为企业管理者界面
                [self setupEnterpriseManagerRootViewController];
                userManager.urlCategate = @"/enterprise";
                break;
            case 2:
                [self setupEnterpriseManagerRootViewController];
                userManager.urlCategate = @"/enterprise";
                break;
            case 3:
                //私有译员（企业版私有用户）（任务：待抢单，进行中）
                [self setupPriviteRootViewController];
                userManager.urlCategate = @"/enterprise";
                break;
            case 4:
                //个人版 （来自客户、来自平台区分，在controller中判定）
                [self setupPriviteRootViewController];
                userManager.urlCategate = @"/personal";
                break;
            case 5://（过期的owner）个人版
                userManager.urlCategate = @"/personal";
                break;
            default://6,7 : 无效用户
                userManager.urlCategate = @"/personal";
                break;
        }

    }else{
        //登录界面
        self.window.rootViewController = [LoginViewController new];
    }
}

//企业管理者
- (void)setupEnterpriseManagerRootViewController {
    MMDrawerController *mmdrawer = [[MJ_UserMessage sharedInstance] setupEnterpriseRootVC];
    [UIApplication sharedApplication].keyWindow.rootViewController = mmdrawer;
    [userManager checkAppVersion];

}

//私有译员(企业版和个人版)
- (void)setupPriviteRootViewController {
    MMDrawerController *mmdrawer = [[MJ_UserMessage sharedInstance] setupPriviteRootVC];
    [UIApplication sharedApplication].keyWindow.rootViewController = mmdrawer;
    [userManager checkAppVersion];
}

- (void)setIQKeyboardTool{
    //键盘处理设置
    IQKeyboardManager *keyboardManager = [IQKeyboardManager sharedManager];
    keyboardManager.enable = NO;
    keyboardManager.shouldResignOnTouchOutside = YES;
    keyboardManager.shouldToolbarUsesTextFieldTintColor = YES;
    keyboardManager.toolbarManageBehaviour = IQAutoToolbarBySubviews;
    keyboardManager.enableAutoToolbar = NO;
    keyboardManager.shouldShowToolbarPlaceholder = YES;
    keyboardManager.placeholderFont = [UIFont boldSystemFontOfSize:17];
    keyboardManager.keyboardDistanceFromTextField = 10.0f;
}

- (void)startMonitoringNetworkReachabilityStatus{
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        // 当网络状态改变时调用
        switch (status) {
            case AFNetworkReachabilityStatusUnknown:
                TGLog(@"当前网络状态：---------- 未知网络 --------------");
                break;
            case AFNetworkReachabilityStatusNotReachable:
                TGLog(@"当前网络状态：------------- 没有网络 -------------");
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN:
                TGLog(@"当前网络状态：------------ 手机自带网络 --------------");
                break;
            case AFNetworkReachabilityStatusReachableViaWiFi:
                TGLog(@"当前网络状态：------------------ WIFI ----------------");
                break;
        }
    }];
    [manager startMonitoring];
}

@end
